from django.contrib import admin
from d115.tasks.models import *
from d115.mixins import *

class TaskCommentInline(admin.StackedInline):
    model = TaskComment
    classes = ('collapse', 'open')
    readonly_fields = ["created_by", "created"]

class TaskAdmin(AuditAdminMixin):
    date_hierarchy = 'created'
    inlines = [TaskCommentInline, ]
    ordering = ["-created",]
    list_display = ["created", "title", "status", "assigned_to", "progress", "priority", "duedate", "comment_count"]
    list_display_links = ["title", "status"]
    search_fields = ('title','content')
    list_filter = ('created', 'created_by', 'assigned_to', 'status', 'priority')
    raw_id_fields = ('assigned_to', )
    class Media:
        pass

try:
    admin.site.unregister(Task)
except:
    pass
admin.site.register(Task, TaskAdmin)
